package com.xteam.youin_supplier.fragment;


import android.os.Bundle;
import android.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.xteam.youin_supplier.MainActivity;
import com.xteam.youin_supplier.R;
import com.xteam.youin_supplier.adpter.MessageListViewAdapter;
import com.xteam.youin_supplier.config.GlobalData;
import com.xteam.youin_supplier.config.RequestAddr;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

/**
 * 消息列表
 */
@EFragment(R.layout.fragment_message_list)
public class MessageListFragment extends BaseFragment {

    @ViewById(R.id.back_btn)
    ImageButton backBtn;

    @ViewById(R.id.toptitle_title)
    TextView topTitle;

    @ViewById(R.id.listview)
    RecyclerView listView;

    MessageListViewAdapter messageListViewAdapter;

    @AfterViews
    @Override
    void initView() {
        backBtn.setVisibility(View.VISIBLE);
        topTitle.setText(getResources().getString(R.string.message_list_title));

        listView.setLayoutManager(new LinearLayoutManager(getActivity()));
        messageListViewAdapter = new MessageListViewAdapter(getActivity().getApplicationContext());
        listView.setAdapter(messageListViewAdapter);

        loadData();

    }

    private void loadData() {
        requestParams = "gasstation_id="+ GlobalData.userInfo.getData();
        requestUrl = RequestAddr.carTeamList + requestParams;
    }

    @Click({R.id.back_btn})
    @Override
    void Click(View view) {
        switch (view.getId()) {
            case R.id.back_btn:
                MainActivity.getInstance().getSupportFragmentManager().popBackStack();
                break;
        }
    }

}
